package com.jiedeng.controller;

import com.jiedeng.dao.ICheckItemTemplateRepository;
import com.jiedeng.model.CheckItemTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 覃远龙
 * @ClassName: CheckItemTemplateController
 * @Description:
 * @date 2017/8/22 14:35
 */
@RestController
@RequestMapping("/checkitemTemplate")
public class CheckItemTemplateController {
    @Autowired
    ICheckItemTemplateRepository checkItemTemplateRepository;

    //----------------- checkItemRule table -------------------//
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public List<CheckItemTemplate> findAll(){
        return checkItemTemplateRepository.findAll();
    }


    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public CheckItemTemplate findCheckItemRule(long id){
        return checkItemTemplateRepository.getOne(id);
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public CheckItemTemplate saveCheckItem(@RequestBody CheckItemTemplate item){
        return checkItemTemplateRepository.save(item);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public void deleteCheckItem(long id){
        checkItemTemplateRepository.deleteById(id);
    }
}
